package kr.saeildamil.androidstudy.ch07;

import kr.saeildamil.androiddforstudy.R;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;

public class Vibrate extends Activity {
	Vibrator mvib;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vibrate);
		mvib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		mvib.cancel();
	}
	
	public void mOnClick(View v){
		switch (v.getId()) {
		case R.id.btnvibrate1:
			mvib.vibrate(500);
			break;
		case R.id.btnvibrate2:
			mvib.vibrate(new long[] {100,50,200,50},0);
			break;
		case R.id.btnvibratestop:
			mvib.cancel();
			break;
		default:
			break;
		}
	}
}
